#Copyright (c) [2019] [Huawei Technologies Co., Ltd.]
#[kiwi-template-openEuler] is licensed under the Mulan PSL v1.
#You can use this software according to the terms and conditions of the Mulan PSL v1.
#You may obtain a copy of Mulan PSL v1 at:
#   http://license.coscl.org.cn/MulanPSL
#   #THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
#PURPOSE.
#See the Mulan PSL v1 for more details.

KIWIIMAGE   = ${buildroot}/usr/share/kiwi/image
RPMNAME     = kiwi-template-openEuler
OUT         = /home/luan/workspace/tmp/

all: build

build:
	@echo Nonthing...

clean:
	@echo Cleaning enviornment...
	@rm -rf $(OUT)/*


install: uninstall
	@echo Installing...
	@install -d -m 755 ${KIWIIMAGE}
	@cp -a template/* ${KIWIIMAGE} &>/dev/null || true


uninstall:
	@echo Uninstalling...
	@rm -rf ${KIWIIMAGE}/openEuler-JeOS
	@rm -rf ${KIWIIMAGE}/openEuler-hmi
	@rm -rf ${KIWIIMAGE}/isoboot/openEuler
	@rm -rf ${KIWIIMAGE}/vmxboot/openEuler
	@rm -rf ${KIWIIMAGE}/oemboot/openEuler

replace:
	@echo Replacing...
	@misc/serpm.py $(PWD)/template/

rpm:
	@echo "Building RPM..."
	@git archive --format=tar --prefix=$(RPMNAME)/ HEAD | bzip2 --best > $(RPMNAME).tar.bz2
	@rm -rf ~/rpmbuild/SOURCES/$(RPMNAME)
	@mv $(RPMNAME).tar.bz2 ~/rpmbuild/SOURCES/
	@rpmbuild -ba rpm/$(RPMNAME).spec

hmi: install
	@echo "Building HMI Image template..."
	@kiwi --build openEuler-JeOS -set-repo iso:///home/openEuler-1.0-aarch64-dvd.iso --type vmx -d $(OUT) 
	@kiwi --build openEuler-JeOS --type vmx -d $(OUT) 

iso: install
	@echo "Building ISO..."
	@kiwi --build openEuler-JeOS --type iso -d $(OUT)

.PHONY: rpm
